<#--<#include "../layout/base.ftl">-->
<#--<#macro header>-->
<style type="text/css">
    #bank-search-panel span.label {
        margin-left: 10px;
    }

    #bank-search-panel .input-text {
        border: 1px solid #6D869E;
        height: 18px;
        vertical-align: middle;
        width: 137px;
    }

    #bank-search-panel span.om-combo, #bank-search-panel span.om-calendar {
        vertical-align: middle;
    }

    .form {
        float: left;
        width: 100%;
        text-align: left;
        border-collapse: collapse;
        background: #fff;
    }

    .form caption {
        font-size: 16px;
        font-weight: bold;
        letter-spacing: 2px;
        color: #19609d
    }

    .form th {
        text-align: right;
        font-size: 14px
    }

    .form tr, .form td {
        padding-left: 3px;
        height: 25px
    }

    .form a:link, .form a:visited {
        color: #246ab5;
        text-decoration: underline
    }

    .form a:hover, .form a:active {
        text-decoration: underline
    }

    .se {
        background: #fafbfe
    }

    .outtable {
        border-collapse: collapse;
    }

    .outtable th {
        border: 1px #d9dde1 solid;
        font-weight: normal;
        color: #173d72;
        text-align: left;
        text-indent: 6px;
        background: #fafbfe;
    }

    .outtable td {
        border: 1px #d9dde1 solid;
        padding: 3px;
        font-size: 14px;
        background: #fff
    }

</style>
<script type="text/javascript">
    $(function () {
        $("#bank-search-panel").omPanel({
            title: "高级搜索"
        });

        $('span#bank-button-search').omButton({
            width: 70,
            icons: {left: '${base}/css/default/images/advanced/search.png'},
            onClick: function (event) {
                var url = "${base}/cfg/bank_grid_json?companyId=" + $("#bank_companyName").val();
                $('#bank_grid').omGrid("setData", encodeURI(url));
            }
        });

        $('#bank_button_bar').omButtonbar({
            width: '100%',
            btns: [
                {id: "save_bank",
                    icons: {left: '${base}/css/default/images/edit_add.png'},
                    label: "保存",
                    onClick: function (event) {
                        var data = "[";
                        var rows = $('#bank_grid').omGrid('getData').rows;
                        for (var i = 0; i < rows.length; i++) {
                            var saving = $("input[name='saving']")[i].value;
                            var loan = $("input[name='loan']")[i].value;

                            var type = $($("select[name='types']")[i]).val();
                            data += "{'bankId':'" + rows[i].bankid + "','saving':'" + saving + "','loan':'" + loan + "','type':'" + type + "'}";
                            data += ','
                        }
                        if (data.length > 1)
                            data = data.substring(data, data.length - 1) + ']';
                        $.post('${base}/cfg/save_bank_grid', {'data': data}, function (data) {
                            var url = "${base}/cfg/bank_grid_json?companyId=" + $("#bank_companyName").val();
                            $('#bank_grid').omGrid("setData", encodeURI(url));
                        });
                    }
                }
            ]
        });

        var url = "${base}/cfg/bank_grid_json?companyId=" + $("#bank_companyName").val();

        var grid = $('#bank_grid').omGrid({
            dataSource: encodeURI(url),
            height: 380,
            width: 'fit',
            limit: 0,
            autoFit: true,
            colModel: [
                {header: '公司名称', name: 'companyName', align: 'left'},
                {header: '银行名称', name: 'bankName', align: 'left'},
                {header: '存款科目', name: 'saving', align: 'center', renderer: function (colValue, rowData, rowIndex) {
                    var data = rowData;
                    return '<input name="saving" type="text"  value="' + colValue + '"></input>';
                }},
                {header: '借款科目', name: 'loan', align: 'center', renderer: function (colValue, rowData, rowIndex) {
                    var data = rowData;
                    return '<input name="loan" type="text"  value="' + colValue + '"></input>';
                }},
                {header: '财字类型', name: 'type', align: 'center', renderer: function (colValue, rowData, rowIndex) {
                    var data = rowData;
                    if (colValue == "1")
                        return '<select name="types"><option value="3">银字</option><option value="1" selected>财字</option></select>';
                    else if (colValue = "3")
                        return '<select name="types"><option value="3" selected>银字</option><option value="1">财字</option></select>';
                    else
                        return '<select name="types"><option value="3" selected>银字</option><option value="1">财字</option></select>';
                }}
            ]
        });

        $(window).scroll(function () {
            $("#bank_grid").omGrid('resize');
        });
    });


</script>
<#--</#macro>-->
<#--<#macro body>-->
<div id="bank-search-panel">
    <div style="width: 800px;">
        <span class="label">公司名称：</span>
        <select id="bank_companyName">
            <option value=""></option>
        <#if companyList??&&companyList?size&gt;0>
            <#list companyList as temp>
                <option value="${temp[0]}">${temp[1]}</option>
            </#list>
        </#if>
        </select>
        <span id="bank-button-search">搜索</span>
    </div>
</div>
<div id="bank_button_bar"/>
<table id="bank_grid">

</table>

